<template>
  <view class="my-container">
    <my-login v-if="!token"></my-login>

    <my-userinfo :likeNum="likeNum" v-else></my-userinfo>
  </view>
</template>

<script>
  import {
    mapState
  } from 'vuex'
  export default {
    computed: {
      ...mapState('m_user', ['token', 'userTrendList', 'userinfo'])
    },
    onShow() {
      // 计算用户获赞数量
      const totalLikeNum = this.userTrendList.reduce((acc, cur) => {
        return acc + cur.likeNum;
      }, 0);
      this.likeNum = totalLikeNum
    },
    data() {
      return {
        likeNum: 0,
      };
    }
  }
</script>

<style lang="scss">
  page,
  .my-container {
    height: 100%;
  }
</style>